@extends('layouts.wechat.application')
@section('content')
    <div id="wrapper" style="display: block">
        <div class="page-product-view" data-log="商品详情">

            <div class="header">
                <div class="left"><a
                            onclick="history.go(-1)"
                            class="home" data-stat-id="346f31c749f6e40d"><img
                                src="http://s1.mi.com/m/images/m/icon_back_n.png" class="ib"></a><!--vue-if-->
                    <!--vue-if--></div>
                <div class="tit"><!--vue-if--></div>
                <div class="right"><a href="javascript:;" data-event="30000000110001001" data-stat-id="6c93ea1c6bb6eb01"
                                      onclick="_msq.push(['trackEvent', '8fb4bea51daee8a5-6c93ea1c6bb6eb01', 'javascript:;', 'pcpid']);">
                        <a href="/product/search">
                            <div class="icon icon-search"></div>
                        </a>
                    </a></div>
            </div>

            <div class="product-view">
                <div class="flexslider ">
                    <ul class="slides">
                        @foreach($product->product_galleries as $product_gallery)
                            <li>
                                <a href=""><img src="{{$product_gallery->img}}"></a>
                            </li>
                        @endforeach

                    </ul>
                </div>

                <div class="b2">
                    <div class="b21">
                        <div class="b211">
                            <div class="name"><p>{{$product->name}}</p></div>
                            <div class="price"><strong>{{$product->price}}元</strong></div>
                        </div>
                        <div class="b212">
                            <div class="icon-fenxiang"></div>
                        </div>
                    </div>
                    <div class="b22">
                        <p>{{$product->description}}</p>
                    </div>
                </div>
                <div class="mt20" style="display: none;"></div>

                <!--<ul class="b3">-->
                <!--<li><span class="on">白色</span></li>-->
                <!--</ul>-->

                <ul class="b3" style="display: none;">
                    <li><span>通用</span></li>
                </ul>

                <div class="ui-b7">
                    <h3>为您推荐</h3>
                    <div class="ui-carousel-container">
                        <div class="ui-carousel-viewport">
                            @foreach($recommends as $recommend)
                                <a href="/product/show?id={{$recommend->id}}">
                                    <img src="{{$recommend->thumb}}">
                                </a>
                            @endforeach
                        </div>
                    </div>
                </div>
                <div class="b5">
                    <div class="b51"></div>
                    <div class="b52">
                        <div class="blc">
                            {!! $product->markdown_html_code !!}
                        </div>
                    </div>
                </div>
                <div class="b7">
                    <div class="b70">
                        <a href="/">
                            <div class="icon-home"></div>
                        </a>
                    </div>
                    <div class="b72" data-id="{{$product->id}}">
                        @if($product->stock == 0)
                            <a href="javascript:;" class="off">暂时缺货</a>
                        @else
                            <a id="add_to_cart">立即购买</a>
                        @endif
                    </div>

                    <div class="b73">
                        <a href="/cart">
                            <div class="icon-gouwuche"></div>
                        </a>
                    </div>
                </div>
                <a href="javascript:;" id="top" style="visibility: visible;">
                    <img src="http://s1.mi.com/m/images/m/top.png">
                </a>
            </div>
            <div class="share-component"></div>
        </div>
    </div>
@endsection
@section('js')
    <script>
        $(function () {
            $('#add_to_cart').click(function () {
                var product_id = $(this).parents('.b72').data('id')
                $.ajax({
                    type: 'POST',
                    url: '/cart/add_cart',
                    data: {product_id: product_id},
                    success: function () {
                        location.href = '/cart';
                    }
                })
//                console.log(product_id);
//                return false;
            });

            $("#top").click(function() {
                $("html,body").animate({scrollTop:0}, 500);
            });
        })
    </script>
@endsection


